import { defHttp } from '/@/utils/http/axios';
import { NovelCategorySearchModel, NovelCategoryVOModel } from './model/novelCategoryModel';
import { BasicDetailModel, BasicDelModel } from '../model/baseModel';

enum Api {
  BaseApi = '/microresource/novel/category',
}

/**
 * @description: 获取小说分类集合数据
 * @author xuyong
 * @date 2025-05-01 11:53:56
 */
export const getCategoryListApi = (data: NovelCategorySearchModel) => {
  return defHttp.post({ url: Api.BaseApi + '/list', data });
};

/**
 * @description: 获取小说分类详细信息
 * @author xuyong
 * @date 2025-05-01 11:53:56
 */
export const getCategoryDetailApi = (categoryId: string) => {
  const data: BasicDetailModel = {
    id: categoryId,
  };
  return defHttp.post({ url: Api.BaseApi + '/detail', data });
};

/**
 * @description: 新增小说分类
 * @author xuyong
 * @date 2025-05-01 11:53:56
 */
export const saveCategoryApi = (data: NovelCategoryVOModel) => {
  return defHttp.post({ url: Api.BaseApi + '/add', data });
};

/**
 * @description: 修改小说分类
 * @author xuyong
 * @date 2025-05-01 11:53:56
 */
export const updateCategoryApi = (data: NovelCategoryVOModel) => {
  return defHttp.post({ url: Api.BaseApi + '/edit', data });
};

/**
 * @description: 删除小说分类
 * @author xuyong
 * @date 2025-05-01 11:53:56
 */
export const delCategoryApi = (categoryIds: string[]) => {
  const data: BasicDelModel = {
    ids: categoryIds,
  };
  return defHttp.post({ url: Api.BaseApi + '/delete', data });
};
